from day1_func import *
# https://www.bilibili.com/video/BV1P14y1L7kP/?p=13&spm_id_from=pageDriver&vd_source=14cc2165480cb62d0e79e6fb3e255b9b
# #1.求和
# num1 = 1.5; num2 = 3
# sum = num1 + num2
# print(sum)
# print(f'{num1}+{num2}={sum}')
# print('{}+{}={}'.format(num1,num2,sum))


# #2.阶乘
# jiecheng1=get_jiecheng(1)
# jiecheng2=get_jiecheng(2)
# jiecheng3=get_jiecheng(3)
# jiecheng4=get_jiecheng(4)
# print(jiecheng1,jiecheng2,jiecheng3,jiecheng4)
#


#3. 圆面积
# area1=computer_circle_area(1)
# area2=computer_circle_area(2)
# print(area1,area2)

# #4. 素数
# prime=number_is_prime(10,25)
# print(prime)

#5. 数字平方和
# number_square_sum=num_square_sum(4)
# print(number_square_sum)

# #6. 列表数字求和
# list=list_sum([1,2,3,4])
# print(list)


# #7. 获取列表范围内偶数
# even=range_even(10,20)
# print(even)
# begin=10;end=20
# data=[item for item in range(begin,end+1) if item%2==0]
# print(data)


# #8. 去除列表元素
#
# list1=[3,5,7,9,11,13]
# list2=[7,11]
# list3=[item for item in list1 if item not in list2 ]
# print(list3)


# #9. 元素去重
# list=[1,2,3,1,2,]
# item_list = []
# for item in list:
#     if item not in item_list:
#         item_list.append(item)
# print(item_list)
# print(set(list))


# #10.列表排序
# list1=[1,3,25,7,4]
# list2=sorted(list1)
# print(list2)
# list2=sorted(list1,reverse=True)
# print(list2)
# list1.sort()
# print(list1)
# list1.sort(reverse=True)
# print(list1)


#11 复杂列表排序
# students = [
#     {"sno": 101,"sname":"小张","sgrade":88},
#     {"sno": 102,"sname":"小王","sgrade": 99},
#     {"sno": 103,"sname":"小李","sgrade":77},
#     {"sno": 104,"sname":"小赵","sgrade":66}]
# students_sort=sorted(students,key=lambda x :x['sgrade'],reverse=True)
# print(students_sort)
#
# lambda x :x['sgrade']
# print(x)

# #12. 读取文件排序
#
# def read_file():
#     result=[]
#     with open('sorc.txt') as file:
#         for line in file:
#             line=line[:-1]
#             result.append(line.split(","))
#     return result
#
# def sort_grades(datas):
#     return sorted(datas,key=lambda x:int(x[0]),reverse=True)
#
#
# def write_file(datas):
#     with open('sorc_out.txt','w') as file_out:
#         for data in datas:
#             file_out.write(",".join(data)+"\n")
#
# # #读取文件
# datas=read_file()
# print(datas)
#
# # #排序
# sort_grades=sort_grades(datas)
# print(sort_grades)
# # #写入
# write_file(sort_grades)

# 13. 计算成绩

def read_file():
    line_list=[]
    with open('sorc_out.txt') as file_in:
        for line in file_in:
            line=line[0:-1]
            line_list.append(line)
    return line_list

def computer_score(data):
    item_list=[]
    for item in data:
        item_list.append(int(item.split(',')[2]))
        print(item)
        # item.split(",")
    return max(item_list),min(item_list)

def data_write(computer):
    write_list=[]
    write_list.append("最高成绩为:"+str(computer[0])+"分")
    write_list.append("最低成绩为:"+str(computer[1])+"分")
    with open('.sorc_computer.txt','w',encoding='utf-8') as file_out:
        for line in write_list:

            file_out.write(line+'\n')

#读取文件
data=read_file()
print(data)
#计算成绩
computer=computer_score(data)
print(computer)

# #写入成绩
data_write(computer)
